package com.example.finaltool.consts;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dengbw
 */
public class AreaCode {
    private AreaCode() {}

    private static final Map<String, Map<String, String>> code;

    static {
        code = new HashMap<>(14);
        putShenyang();
        putDalian();
        putAnshan();
        putFushun();
        putBenxi();
        putDandong();
        putJinzhou();
        putYingkou();
        putFuxin();
        putLiaoyang();
        putPanjin();
        putTieling();
        putChaoyang();
        putHuludao();
    }

    public static String get(String shi, String qu) {
        if (!shi.endsWith("市")) {
            shi = shi + "市";
        }
        if (code.containsKey(shi) && code.get(shi).containsKey(qu)) {
            return code.get(shi).get(qu);
        }
        return "";
    }

    private static void putShenyang() {
        Map<String, String> shenyang = new HashMap<>(13);
        shenyang.put("和平区", "02");
        shenyang.put("和平", "02");
        shenyang.put("沈河区", "03");
        shenyang.put("沈河", "03");
        shenyang.put("大东区", "04");
        shenyang.put("大东", "04");
        shenyang.put("皇姑区", "05");
        shenyang.put("皇姑", "05");
        shenyang.put("铁西区", "06");
        shenyang.put("铁西", "06");
        shenyang.put("苏家屯区", "11");
        shenyang.put("苏家屯", "11");
        shenyang.put("浑南区", "12");
        shenyang.put("浑南", "12");
        shenyang.put("沈北新区", "13");
        shenyang.put("沈北", "13");
        shenyang.put("于洪区", "14");
        shenyang.put("于洪", "14");
        shenyang.put("辽中区", "15");
        shenyang.put("辽中", "15");
        shenyang.put("康平县", "23");
        shenyang.put("康平", "23");
        shenyang.put("法库县", "24");
        shenyang.put("法库", "24");
        shenyang.put("新民市", "81");
        shenyang.put("新民", "81");
        code.put("沈阳市", shenyang);
    }

    private static void putDalian() {
        Map<String, String> dalian = new HashMap<>(10);
        dalian.put("中山区", "02");
        dalian.put("中山", "02");
        dalian.put("西岗区", "03");
        dalian.put("西岗", "03");
        dalian.put("沙河口区", "04");
        dalian.put("沙河口", "04");
        dalian.put("甘井子区", "11");
        dalian.put("甘井子", "11");
        dalian.put("旅顺口区", "12");
        dalian.put("旅顺口", "12");
        dalian.put("金州区", "13");
        dalian.put("金州", "13");
        dalian.put("普兰店区", "14");
        dalian.put("普兰店", "14");
        dalian.put("普兰店市", "14");
        dalian.put("长海县", "24");
        dalian.put("长海", "24");
        dalian.put("瓦房店市", "81");
        dalian.put("瓦房店", "81");
        dalian.put("庄河市", "83");
        dalian.put("庄河", "83");
        code.put("大连市", dalian);
    }

    private static void putAnshan() {
        Map<String, String> city = new HashMap<>(7);
        city.put("铁东区", "02");
        city.put("铁东", "02");
        city.put("铁西区", "03");
        city.put("铁西", "03");
        city.put("立山区", "04");
        city.put("立山", "04");
        city.put("千山区", "11");
        city.put("千山", "11");
        city.put("台安县", "21");
        city.put("台安", "21");
        city.put("岫岩满族自治县", "23");
        city.put("岫岩县", "23");
        city.put("岫岩", "23");
        city.put("海城市", "81");
        city.put("海城", "81");
        code.put("鞍山市", city);
    }

    private static void putFushun() {
        Map<String, String> city = new HashMap<>(7);
        city.put("新抚区", "02");
        city.put("东洲区", "03");
        city.put("望花区", "04");
        city.put("顺城区", "11");
        city.put("抚顺县", "21");
        city.put("新宾满族自治县", "22");
        city.put("清原满族自治县", "23");
        city.put("新抚", "02");
        city.put("东洲", "03");
        city.put("望花", "04");
        city.put("顺城", "11");
        city.put("抚顺", "21");
        city.put("新宾", "22");
        city.put("清原", "23");
        city.put("新宾县", "22");
        city.put("清原县", "23");
        code.put("抚顺市", city);
    }

    private static void putBenxi() {
        Map<String, String> city = new HashMap<>(6);
        city.put("平山区", "02");
        city.put("溪湖区", "03");
        city.put("明山区", "04");
        city.put("南芬区", "05");
        city.put("本溪满族自治县", "21");
        city.put("桓仁满族自治县", "22");
        city.put("平山", "02");
        city.put("溪湖", "03");
        city.put("明山", "04");
        city.put("南芬", "05");
        city.put("本溪县", "21");
        city.put("桓仁县", "22");
        code.put("本溪市", city);
    }

    private static void putDandong() {
        Map<String, String> city = new HashMap<>(6);
        city.put("元宝区", "02");
        city.put("振兴区", "03");
        city.put("振安区", "04");
        city.put("东港市", "81");
        city.put("凤城市", "82");
        city.put("宽甸满族自治县", "24");
        city.put("元宝", "02");
        city.put("振兴", "03");
        city.put("振安", "04");
        city.put("东港", "81");
        city.put("凤城", "82");
        city.put("宽甸县", "24");
        city.put("宽甸", "24");
        code.put("丹东市", city);
    }

    private static void putJinzhou() {
        Map<String, String> city = new HashMap<>(7);
        city.put("古塔区", "02");
        city.put("凌河区", "03");
        city.put("太和区", "11");
        city.put("黑山县", "26");
        city.put("凌海市", "81");
        city.put("北镇市", "82");
        city.put("义县", "27");
        city.put("古塔", "02");
        city.put("凌河", "03");
        city.put("太和", "11");
        city.put("黑山", "26");
        city.put("凌海", "81");
        city.put("北镇", "82");
        city.put("义", "27");
        code.put("锦州市", city);
    }

    private static void putYingkou() {
        Map<String, String> city = new HashMap<>(6);
        city.put("站前区", "02");
        city.put("西市区", "03");
        city.put("鲅鱼圈区", "04");
        city.put("老边区", "11");
        city.put("盖州市", "81");
        city.put("大石桥市", "82");
        city.put("站前", "02");
        city.put("西市", "03");
        city.put("鲅鱼圈", "04");
        city.put("老边", "11");
        city.put("盖州", "81");
        city.put("大石桥", "82");
        code.put("营口市", city);
    }

    private static void putFuxin() {
        Map<String, String> city = new HashMap<>(7);
        city.put("海州区", "02");
        city.put("新邱区", "03");
        city.put("太平区", "04");
        city.put("清河门区", "05");
        city.put("细河区", "11");
        city.put("彰武县", "22");
        city.put("阜新蒙古族自治县", "21");
        city.put("海州", "02");
        city.put("新邱", "03");
        city.put("太平", "04");
        city.put("清河门", "05");
        city.put("细河", "11");
        city.put("彰武", "22");
        code.put("阜新市", city);
    }

    private static void putLiaoyang() {
        Map<String, String> city = new HashMap<>(7);
        city.put("白塔区", "02");
        city.put("文圣区", "03");
        city.put("宏伟区", "04");
        city.put("弓长岭区", "05");
        city.put("太子河区", "11");
        city.put("辽阳县", "21");
        city.put("灯塔市", "81");
        city.put("白塔", "02");
        city.put("文圣", "03");
        city.put("宏伟", "04");
        city.put("弓长岭", "05");
        city.put("太子河", "11");
        city.put("辽阳", "21");
        city.put("灯塔", "81");
        code.put("辽阳市", city);
    }

    private static void putPanjin() {
        Map<String, String> city = new HashMap<>(4);
        city.put("双台子区", "02");
        city.put("兴隆台区", "03");
        city.put("大洼区", "04");
        city.put("盘山县", "22");
        city.put("双台子", "02");
        city.put("兴隆台", "03");
        city.put("大洼", "04");
        city.put("盘山", "22");
        code.put("盘锦市", city);
    }

    private static void putTieling() {
        Map<String, String> city = new HashMap<>(7);
        city.put("银州区", "02");
        city.put("清河区", "04");
        city.put("铁岭县", "21");
        city.put("西丰县", "23");
        city.put("昌图县", "24");
        city.put("调兵山市", "81");
        city.put("开原市", "82");
        city.put("银州", "02");
        city.put("清河", "04");
        city.put("铁岭", "21");
        city.put("西丰", "23");
        city.put("昌图", "24");
        city.put("调兵山", "81");
        city.put("开原", "82");
        code.put("铁岭市", city);
    }

    private static void putChaoyang() {
        Map<String, String> city = new HashMap<>(6);
        city.put("双塔区", "02");
        city.put("龙城区", "03");
        city.put("朝阳县", "21");
        city.put("建平县", "22");
        city.put("北票市", "81");
        city.put("凌源市", "82");
        city.put("喀喇沁左翼蒙古族自治县", "24");
        city.put("双塔", "02");
        city.put("龙城", "03");
        city.put("朝阳", "21");
        city.put("建平", "22");
        city.put("北票", "81");
        city.put("凌源", "82");
        city.put("喀左县", "24");
        city.put("喀左", "24");
        code.put("朝阳市", city);
    }

    private static void putHuludao() {
        Map<String, String> city = new HashMap<>(6);
        city.put("连山区", "02");
        city.put("龙港区", "03");
        city.put("南票区", "04");
        city.put("绥中县", "21");
        city.put("建昌县", "22");
        city.put("兴城市", "81");
        city.put("连山", "02");
        city.put("龙港", "03");
        city.put("南票", "04");
        city.put("绥中", "21");
        city.put("建昌", "22");
        city.put("兴城", "81");
        code.put("葫芦岛市", city);
    }
}
